#include<iostream>
#include<list>
using namespace std;



void printList(const list<int>& l){
	
	for(list<int>::const_iterator it=l.begin();it!=l.end();it++){
		
		cout<<*it<<" ";
	
	}
	cout<<endl;

}
int main(){

	list<int> l={-1,9,8,5,2,1,1,-1};
	printList(l);
	l.pop_back();
	printList(l);
	l.pop_front();
	printList(l);



	list<int>::iterator it=l.erase(l.begin());
	printList(l);
	cout<<*it<<endl;


	l.erase(it);
	printList(l);
	cout<<*it<<endl;

	it++;
	it++;
	l.erase(it,l.end());
	printList(l);

	l.clear();
	printList(l);

	cout<<"l.size():"<<l.size()<<endl;


	return 0;
}
